<template>
	<view class="content">
		<view class="title">
			子组件B
		</view>
		<view class="b-box">
			CompA组件传进来的值:
			<text class="intent-text-box">{{ result }}</text>
		</view>
		<view class="b-box b-margin">
			<text>回传值：</text>
			<input type="text" v-model="callbackValue" class="input-yellow" />
			<button @click="sendOutside()" size="mini">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "ComBView",
		data() {
			return {

			};
		},
		created() {
		  uni.$on('getIntent', (msg) => {
		    console.error("---CompBView---getIntent----->" + msg);
		    this.result = msg;
		  });
		},
		methods:{
			sendOutside() {
			  console.warn("---ComBView---sendOutside----->" + this.callbackValue);
			  this.$emit('callBackFun', this.callbackValue);
			}
		}
	}
</script>

<style>
	.content {
		padding: 20rpx;
		margin-top: 25rpx;
		background-color: #00557f;
		color: white;
		border-radius: 10rpx;
	}

	.title {
		font-size: 40rpx;
		text-align: center;
		margin-bottom: 20rpx;
	}

	.b-box {
		margin-bottom: 20rpx;
		padding: 15rpx;
		background-color: rgba(255, 0, 0, 0.8);
		border-radius: 8rpx;
		color: #333;
	}

	.b-margin {
		margin: 10rpx;
	}

	.intent-text-box {
		font-weight: bold;
		color: blue;
		font-size: 32rpx;
	}

	.input-yellow {
		color: yellow;
		border: 1px solid #55ff7f;
		padding: 10rpx;
		width: 200rpx;
		margin-right: 10rpx;
	}

	button {
		margin-top: 20rpx;
	}
</style>